package br.com.sistema.smallAgro.modelo;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import br.com.sistema.smallAgro.base.IEntidade;
import br.com.sistema.smallAgro.enums.SimNao;

@Entity
@Table(name = "TB_USUARIO")
public class Usuario implements IEntidade {
	private static final long serialVersionUID = -5801513707051832437L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "CO_SEQ_USUARIO", length = 20, nullable = true)
	private Long codigo;

	@Column(name = "DS_LOGIN", length = 45, nullable = false)
	private String login;

	@Column(name = "DS_NOME", length = 80, nullable = false)
	private String nome;

	@Column(name = "DS_SENHA", length = 20, nullable = false)
	private String senha;

	@Enumerated(EnumType.STRING)
	@Column(name = "ST_STATUS")
	private SimNao status = SimNao.S;

	@Transient
	private String confirmacaoSenha;

	public Long getCodigo() {
		return codigo;
	}

	public void setCodigo(Long codigo) {
		this.codigo = codigo;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public String getSenha() {
		return senha;
	}

	public void setSenha(String senha) {
		this.senha = senha;
	}

	public SimNao getStatus() {
		return status;
	}

	public void setStatus(SimNao status) {
		this.status = status;
	}

	@Override
	public Long getId() {
		return codigo;
	}

	public String getConfirmacaoSenha() {
		return confirmacaoSenha;
	}

	public void setConfirmacaoSenha(String confirmacaoSenha) {
		this.confirmacaoSenha = confirmacaoSenha;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((codigo == null) ? 0 : codigo.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Usuario other = (Usuario) obj;
		if (codigo == null) {
			if (other.codigo != null)
				return false;
		} else if (!codigo.equals(other.codigo))
			return false;
		return true;
	}

}
